package com.jfire.codejson.methodinfo.impl.write;

import java.lang.reflect.Method;
import com.jfire.codejson.util.NameTool;

public class ReturnCustomObjectMethodInfo extends AbstractWriteMethodInfo
{
    
    public ReturnCustomObjectMethodInfo(Method method)
    {
        super(method);
        Class<?> returnType = method.getReturnType();
        String fieldName = NameTool.getNameFromMethod(method);
        str = returnType.getName() + " " + fieldName + " = " + getValue + ";\n";
        str += "if(" + fieldName + "!=null)\n{\n";
        str += "\tcache.append(\"\\\"" + fieldName + "\\\":\");\n";
        str += "\tWriterContext.write(" + fieldName + ",cache);\n";
        str += "\tcache.append(',');\n";
        str += "}\n";
    }
    
}
